<script>
import NavBar from '@/components/NavBar.vue'; // 导入导航栏组件

export default {
  components: {
    NavBar // 注册导航栏组件
  },
  data() {
    const storedActivities = localStorage.getItem('activities');
    let activities = [];

    if (storedActivities) {
      try {
        activities = JSON.parse(storedActivities);
      } catch (e) {
        // 解析失败时使用默认数据
        import('@/data/activities.js').then(module => {
          activities = module.default;
        });
      }
    } else {
      import('@/data/activities.js').then(module => {
        activities = module.default;
      });
    }
    
    return {
      activities
    };
  }
};
</script>

<style scoped>
.activities-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.main-content {
  width: 100%;
  max-width: 800px;
  text-align: center;
}

.activities-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.activity-card {
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  width: 200px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.activity-card h2 {
  font-size: 1.2em;
  margin-bottom: 10px;
}

.activity-card p {
  font-size: 1em;
  margin-bottom: 10px;
}

.detail-button {
  display: inline-block;
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.detail-button:hover {
  background-color: #0056b3;
}

</style>